package client.comm.baoding.ui.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import client.comm.commlib.network.data.JsonResult
import client.comm.commlib.network.data.Ret
import client.comm.baoding.ui.viewmodel.MiddleVm

import org.json.JSONObject

class ApplyTuikuanModel(app: Application) : MiddleVm(app) {

    val isShowing = MutableLiveData<Boolean>(false)
    val commitRet = MutableLiveData<JsonResult<Ret>>()
    val wuliu = MutableLiveData<String>()
    val wuliuNum = MutableLiveData<String>()
    val typeBack = MutableLiveData<Int>(0)
    val isShowWl = MutableLiveData<Boolean>(false)
    val typeTxt = MutableLiveData<String>("")

    fun commitOrder(obj: JSONObject) {
        hold({
//            val body = RequestBody.create(
//                "application/json;charset=UTF-8".toMediaTypeOrNull(),
//                obj.toString()
//            )
            server.applyTuikuan(
                obj.getString("order_goods_id"),
                obj.getString("num"),
                obj.getString("back_status"),
                obj.getString("logistics_name"),
                obj.getString("logistics_num"),
            )
        }, {
            isShowing.value = true
        }, {
            commitRet.value = it
        }, complete = {
            isShowing.value = false
        })
    }

}